<template>
  <div class="padding-l-20 padding-r-20 padding-t-20 _dashboard">
    <filter-bar>
      <template slot="left-bar">
        <a-space>
          <a-button
            @click="edit(0)"
            class="nbcs-btn nbcs-btn-danger"
            >全部停用</a-button>
            <a-button
            @click="edit(0)"
            class="nbcs-btn nbcs-btn-primary"
            >全部启用</a-button>
          <a-input-search
            class="position-r"
            placeholder="请输入设备名称搜索"
            enter-button
            @pressEnter="getList(page,searchForm)"
            @search="getList(page,searchForm)"
            v-model="searchForm.name"
          />
          </a-space>
        
      </template>
    </filter-bar>
    <company-list ref="companyList" @getTotal="getTotal"></company-list>
    <base-pagination :current="page.page" :total="total" :pageSize="page.pageSize"
      @pageChange="onPageChange" @showSizeChange="onShowSizeChange"></base-pagination>
    <company-form ref="companyForm" @getList="page.page = 1;getList(page,searchForm)"></company-form>
  </div>
</template>
<script>
import filterBar from '@/layouts/FilterBar'
import companyList from '@/pages/company/companyList'
import companyForm from '@/pages/company/companyForm'
import BasePagination from '@/components/basic/BasePagination'

export default {
  name: "company",
  components: {
    filterBar,companyForm,BasePagination,
    companyList
  },
  data() {
    return {
      searchForm:{
        name:''
      },
      page:{
        page:1,
        pageSize:20
      },
      total:0
    };
  },
  computed: {},
  created() {
  },
  mounted () {
    this.getList(this.page,this.searchForm);
  },
  methods: {
    getList(page,searchForm){
      this.$refs['companyList'].getTenant(page,searchForm);
    },
    edit(action, data = {}){
      this.$refs['companyForm'].changeForm(true,action,data);
    },
    getTotal(total){
      this.total = total;
    },
    onPageChange(page){
      this.page.page = page.page;
      this.getList(page,this.searchForm)
    },
    onShowSizeChange(page){
      this.page.page = 1;
      this.page.pageSize = page.pageSize;
      this.getList(this.page,this.searchForm)
    },
  },
};
</script>

<style lang="less" scoped>
._dashboard{
  height: 100%;
  display: flex;
  flex-direction: column;
}
</style>
